﻿using System;
using WhatCatch.Core2;
using WhatCatch.Core2.Model;

namespace WhatCatch.Demo2
{
    class Program
    {
        static void Main(string[] args)
        {
            //DataContainer dataContainer = new DataContainer();
            ////dataContainer.AddListUrl("http://www.test.com/page/1", 1);
            //dataContainer.AddListUrl("http://www.qimaoyun.cn/information/page/1", 1);

            ICatchQueue catchQueue = new CatchQueue();

            //启动服务
            CrawlerService crawlerService = new CrawlerService(catchQueue);
            crawlerService.Run();
            crawlerService.AddTask(new CatchTask
            {

                TaskId = 1,
                Url = "http://www.test.com/page/1",
                ResourceId = 1,
                HandleType = 1,
                Config = new ResourceConfig
                {
                    ListXPath = "",
                    ListItemXPath = "//div[@class='list']/div[@class='list-li']",
                    ListItemUrlXPath = "",
                    PageXPath = "",
                    PageItemXPath = "//div[@class='page']/a",
                    PageItemUrlXPath = "",
                    DetailXPath = "",
                    DetailTitleXPath = "//div[@class='detail-title']",
                }
            });

            //启动客户端
            HandleConfig config = new HandleConfig
            {
                HandleThreadNum = 1
            };
            CrawlerClient crawlerClient = new CrawlerClient(config, catchQueue);
            crawlerClient.Run();

            Console.Read();

        }
    }
}
